package cn.chia.back.dao.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import org.springframework.stereotype.Component;

import cn.chia.back.dao.ICSDAO;
import cn.chia.pojo.Customerservices;
import cn.chia.pojo.Peisongren;
@Component
public class CSDAOImpl extends HibernateDaoSupport implements ICSDAO {

	@Autowired
	public CSDAOImpl(HibernateTemplate hibernateTemplate){
		super.setHibernateTemplate(hibernateTemplate);
	}
	/*
	 * 于辉  根据客服名、密码查找客服
	 */
	public List<?> findByUserPass(String csname, String password) {
		return super.getHibernateTemplate().find("from Customerservices where csname='"+csname+"' and password='"+password+"'");
	}
	/*
	 * 于辉  增加客服
	 */
	public void doCreate(Customerservices vo) throws Exception {
		super.getHibernateTemplate().save(vo);
	}

	public void doRemove(Integer id) throws Exception {

	}
	/*
	 * 于辉  修改客服
	 */
	public void doUpdate(Customerservices vo) throws Exception {
		super.getHibernateTemplate().update(vo);
	}
	/*
	 * 于辉  查询所有的客服
	 */
	public List<Customerservices> findAll() throws Exception {
		return super.getHibernateTemplate().find("from Customerservices where flag = 1 order by id");
	}

	public List<Customerservices> findAll(int pageNo, int pageSize,
			String keyword, String column) throws Exception {
		return null;
	}
	/*
	 * 于辉  根据id查找客服
	 */
	public Customerservices findById(Integer id) throws Exception {
		return (Customerservices) super.getHibernateTemplate().find("from Customerservices where id='"+id+"'").get(0);
	}

	public int getAllCount(String keyword, String column) throws Exception {
		return 0;
	}

}
